package com.zhentao.controller;

import com.github.pagehelper.PageInfo;
import com.zhentao.common.Result;
import com.zhentao.domain.SysUser;
import com.zhentao.domain.dto.LoginDto;
import com.zhentao.domain.dto.PageDto;
import com.zhentao.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: SysUserController
 * @Desrciption: Mr.chengfenzhan
 * @Author: 知安_程烽展
 * @Date: 2024/9/3 9:08
 */
@RestController
@RequestMapping("/sysuser")
@Tag(name = "用户管理")
public class SysUserController {
    @Autowired
    private SysUserService service;
    @PostMapping("/login")
    @Operation(summary = "登录")
    public Result login(@RequestBody LoginDto loginDto){
        return service.login(loginDto);
    }

    @GetMapping("/userinfo")
    @Operation(summary = "获取用户信息")
    public Result getUserInfo(){
        return service.getUserInfo();
    }
    @PostMapping("/addUser")
    @Operation(summary = "添加用户")
    public Result addUser(@RequestBody LoginDto loginDto){
        return service.addUser(loginDto);
    }
//    用户信息分页查询展示
    @PostMapping("/getUserList")
    public Result getUserList(@RequestBody PageDto pageDto){
        PageInfo<SysUser> userList = service.getUserList(pageDto);
        return Result.build(userList,200,"查询成功");
    }
    @PostMapping("/add")
    public int add(String phone){
        return service.add(phone);
    }
    @PostMapping("/delete")
    public int delete(Integer id){
        return service.delete(id);
    }
    @PostMapping("/update")
    public int update(SysUser sysUser){
        return service.update(sysUser);
    }
}
